#include "count.h"
#include "ui_count.h"
#include <QTime>

count::count(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::count)
{
    ui->setupUi(this);
    connect(&mytimer,&QTimer::timeout,this,&count::timer_fun);
}

count::~count()
{
    delete ui;
}

void count::on_back_clicked()
{
    this->parentWidget()->show();
    this->hide();
}



void count::timer_fun()
{
    a++;
    QTime time(a/3600,a/60%60,a%60);
    QString text_time = time.toString("hh::mm::ss");
    ui->times->setText(text_time);
}

void count::on_start_clicked()
{
    mytimer.start(10);
}

void count::on_stop_clicked()
{
    mytimer.stop();
}

void count::on_res_clicked()
{

    mytimer.stop();
    a=0;
//    QTime time(a/3600,a/60%60,a%60);
//    QString text_time = time.toString("hh::mm::ss");
//    ui->times->setText(text_time);
    ui->times->clear();
    ui->time_list->clear();
}


void count::on_rec_clicked()
{
    QString text_time = ui->times->text();
    ui->time_list->addItem(text_time);
}
